﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;
using SponsorshipManager.Interfaces;
using SponsorshipManager.Client.Model;

namespace SponsorshipManager.Client.ViewModel
{
    class Welcome : INotifyPropertyChanged  
    {
        public Welcome()
        {
            User.ChangedCurrentUser += CurrentUserChanged;
        }

        public User CurrentUser 
        {
            get
            {
                return (User)User.CurrentUser;
            }
        }

        public Person UserDetails
        {
            get
            {
                return (CurrentUser == null) ? null : (Person)CurrentUser.Person;
            }
        }

        private void CurrentUserChanged(IUser currentUser)
        {
            PropertyChanged(this, new PropertyChangedEventArgs("LoginLinkVisiblity"));
            PropertyChanged(this, new PropertyChangedEventArgs("PersonInfoVisiblity"));
        }

        public Visibility VisibleWhenNotLoggedIn
        {
            get
            {
                if (CurrentUser == null)
                    return Visibility.Visible;
                else
                    return Visibility.Collapsed;
            }
        }

        public Visibility VisibleWhenLoggedIn
        {
            get
            {
                if (CurrentUser != null)
                    return Visibility.Visible;
                else
                    return Visibility.Collapsed;

            }

        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
